const fs = require('fs');
const routeMap = require('./route-map');

const proxy = {};

const getJSONFile = filename => {
  return (req, res) => {
    const data = fs.readFileSync(`__mock__/data/${filename}.json`).toString();
    const json = JSON.parse(data);
    return res.json(json);
  };
};

for (const key in routeMap) {
  proxy[key] = getJSONFile(routeMap[key]);
}

module.exports = proxy;
